﻿$(document).ready(function () {

    function getResource(url) {
        $.ajax({
            url: url,
            dataType: 'json',
            type: 'GET',
            contentType: 'application/json; charset=utf-8',
            success: function (data, textStatus, jqXHR) {
                $('#container').html(_.jsonreport(JSON.stringify(data)));
                $('.mylink').click(function () {
                    getResource(this.href);
                    return false;
                });
            }
        });
    }

    (function () {
        //let's start here...
        getResource('http://localhost:51985/mlb/franchises/all');
    } ());



//    function deSerialize(str) {
//        var team = JSON.parse(str);
//        alert(team.Players[2].Description);
//    }

//    (function deleteMe() {
//        var x = {
//            "Ballpark": "Sportsman's Park IV",
//            "Finish": 1,
//            "Franchise": {
//                "Description": "St. Louis Cardinals",
//                "Uri": "http://localhost:51985/mlb/franchise/101"
//            },
//            "League": "National League",
//            "LgWinner": true,
//            "Nickname": "St. Louis Cardinals",
//            "Players": [
//                { "Description": "Buster Adams", "Uri": "" },
//                { "Description": "Red Barrett", "Uri": "" },
//                { "Description": "Nippy Jones", "Uri": "" },
//                { "Description": "Clyde Kluttz", "Uri": "" },
//                { "Description": "Howie Krist", "Uri": "" },
//                { "Description": "Whitey Kurowski", "Uri": "" },
//                { "Description": "Stan Musial", "Uri": "" },
//                { "Description": "Red Schoendienst", "Uri": "" },
//                { "Description": "Enos Slaughter", "Uri": "" },
//            ],
//            "WSWinner": true,
//            "Year": 1946
//        }
//        var str = JSON.stringify(x);
//        deSerialize(str);
//        console.log(str);
//    } ());






});